/* ==========================================================================
   CONTRA - 魂斗罗 Web复刻版 CSS样式表
   ========================================================================== */

/* 重置和基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* 游戏容器 */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #000;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    background: #000;
}

/* ==========================================================================
   覆盖层样式（开始界面、游戏结束等）
   ========================================================================== */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.9);
    z-index: 100;
    color: #fff;
}

.overlay.hidden {
    display: none;
}

/* 闪烁动画 */
@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

.blink {
    animation: blink 1s step-end infinite;
}

/* 开始界面样式 */
#start-screen {
    background: linear-gradient(180deg, #000 0%, #1a0a0a 50%, #000 100%);
}

.title-container {
    text-align: center;
    margin-bottom: 30px;
}

.game-title {
    font-size: clamp(32px, 8vw, 72px);
    color: #ff6b35;
    text-shadow: 
        4px 4px 0 #000,
        -2px -2px 0 #d42d27,
        0 0 20px rgba(255, 107, 53, 0.5);
    letter-spacing: 8px;
    animation: titleGlow 2s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% { text-shadow: 4px 4px 0 #000, -2px -2px 0 #d42d27; }
    100% { text-shadow: 4px 4px 0 #000, -2px -2px 0 #d42d27, 0 0 30px rgba(255, 107, 53, 0.8); }
}

.game-subtitle {
    font-size: clamp(16px, 4vw, 28px);
    color: #fff;
    margin-top: 15px;
    letter-spacing: 4px;
}

.game-version {
    font-size: 12px;
    color: #888;
    margin-top: 20px;
}

/* 角色预览 */
.character-preview {
    display: flex;
    gap: 60px;
    margin: 30px 0;
}

.character-preview .bill,
.character-preview .lance {
    width: 40px;
    height: 80px;
    position: relative;
    animation: characterBounce 0.5s ease-in-out infinite alternate;
}

.character-preview .bill {
    background: linear-gradient(to bottom, 
        #d42d27 0%, #d42d27 15%,
        #e8c39e 15%, #e8c39e 30%,
        #fff 30%, #fff 60%,
        #2b5c96 60%, #2b5c96 100%);
}

.character-preview .lance {
    background: linear-gradient(to bottom, 
        #4a7c4e 0%, #4a7c4e 15%,
        #e8c39e 15%, #e8c39e 30%,
        #fff 30%, #fff 60%,
        #8b4513 60%, #8b4513 100%);
    animation-delay: 0.25s;
}

@keyframes characterBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

.start-prompt {
    margin-top: 40px;
    font-size: clamp(10px, 2.5vw, 18px);
    color: #ff6b35;
}

.credits {
    position: absolute;
    bottom: 30px;
    text-align: center;
    font-size: 10px;
    color: #888;
    line-height: 2;
}

/* 游戏结束界面 */
#game-over-screen {
    background: rgba(139, 0, 0, 0.95);
}

.game-over-text {
    font-size: clamp(28px, 7vw, 56px);
    color: #ff0000;
    text-shadow: 4px 4px 0 #000;
    margin-bottom: 40px;
    animation: gameOverPulse 0.5s ease-in-out infinite alternate;
}

@keyframes gameOverPulse {
    0% { transform: scale(1); }
    100% { transform: scale(1.05); }
}

.final-score {
    text-align: center;
    line-height: 3;
    font-size: clamp(12px, 3vw, 24px);
}

.final-score .hud-value {
    color: #ff6b35;
}

.continue-prompt {
    margin-top: 40px;
    color: #fff;
    font-size: clamp(10px, 2vw, 16px);
}

/* 关卡完成界面 */
#level-clear-screen {
    background: rgba(0, 100, 0, 0.95);
}

.stage-clear-text {
    font-size: clamp(28px, 7vw, 48px);
    color: #00ff00;
    text-shadow: 4px 4px 0 #000;
    margin-bottom: 30px;
}

.stage-bonus {
    text-align: center;
    line-height: 2.5;
    font-size: clamp(12px, 3vw, 20px);
}

/* 继续倒计时界面 */
#continue-screen {
    background: rgba(0, 0, 100, 0.95);
}

.continue-text {
    font-size: clamp(24px, 6vw, 48px);
    color: #fff;
    margin-bottom: 30px;
}

.countdown {
    font-size: clamp(48px, 12vw, 96px);
    color: #ffff00;
    animation: countdownPulse 1s ease-in-out infinite;
}

@keyframes countdownPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

/* ==========================================================================
   游戏HUD界面
   ========================================================================== */
#game-hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 50;
    pointer-events: none;
}

#game-hud.hidden {
    display: none;
}

.hud-left,
.hud-right {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.score-container,
.lives-container,
.stage-container,
.weapon-container,
.high-score {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hud-label {
    font-size: clamp(8px, 1.5vw, 14px);
    color: #888;
    text-shadow: 2px 2px 0 #000;
}

.hud-value {
    font-size: clamp(10px, 2vw, 18px);
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    min-width: 80px;
}

.lives-icons {
    display: flex;
    gap: 4px;
}

.life-icon {
    width: 14px;
    height: 18px;
    background: #ff6b35;
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

#stage-name {
    color: #ff6b35;
}

#weapon-display {
    color: #00ff00;
}

/* ==========================================================================
   移动端控制样式
   ========================================================================== */
#mobile-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 50%;
    z-index: 60;
    display: none;
    pointer-events: none;
}

#mobile-controls.active {
    display: block;
}

/* 方向键 */
.d-pad {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 150px;
    height: 150px;
    pointer-events: auto;
}

.d-pad-center {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

.d-pad-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: rgba(255, 255, 255, 0.8);
    transition: all 0.1s ease;
}

.d-pad-btn:active,
.d-pad-btn.active {
    background: rgba(255, 107, 53, 0.6);
    border-color: #ff6b35;
    transform: scale(0.95);
}

.d-pad-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.d-pad-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.d-pad-left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.d-pad-right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

/* 操作按钮 */
.action-buttons {
    position: absolute;
    bottom: 40px;
    right: 30px;
    display: flex;
    gap: 20px;
    pointer-events: auto;
}

.action-btn {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.5);
    font-family: 'Press Start 2P', cursive;
    font-size: 24px;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.1s ease;
    backdrop-filter: blur(5px);
}

.btn-a {
    background: rgba(255, 107, 53, 0.4);
    border-color: #ff6b35;
}

.btn-b {
    background: rgba(255, 0, 0, 0.4);
    border-color: #ff0000;
}

.action-btn:active,
.action-btn.active {
    transform: scale(0.9);
    filter: brightness(1.3);
}

/* ==========================================================================
   响应式设计
   ========================================================================== */

/* 平板设备 */
@media (max-width: 1024px) and (orientation: landscape) {
    .d-pad {
        width: 120px;
        height: 120px;
    }
    
    .action-btn {
        width: 60px;
        height: 60px;
        font-size: 20px;
    }
    
    .d-pad-btn {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
}

/* 手机横屏 */
@media (max-width: 768px) and (orientation: landscape) {
    .d-pad {
        width: 100px;
        height: 100px;
        bottom: 20px;
        left: 15px;
    }
    
    .action-buttons {
        bottom: 25px;
        right: 15px;
        gap: 15px;
    }
    
    .action-btn {
        width: 55px;
        height: 55px;
        font-size: 18px;
    }
    
    .d-pad-btn {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .d-pad-center {
        width: 30px;
        height: 30px;
    }
}

/* 超小屏幕优化（新增） */
@media (max-width: 360px) and (orientation: landscape) {
    .d-pad {
        width: 80px;
        height: 80px;
        bottom: 10px;
        left: 5px;
    }
    .action-btn {
        width: 45px;
        height: 45px;
        font-size: 14px;
    }
    .d-pad-btn {
        width: 26px;
        height: 26px;
        font-size: 10px;
    }
}

/* 手机竖屏（强制横屏提示） */
@media (max-width: 576px) and (orientation: portrait) {
    #game-container::before {
        content: "请旋转设备至横屏模式以获得最佳体验";
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        color: #fff;
        font-size: 14px;
        text-align: center;
        z-index: 200;
        background: rgba(0, 0, 0, 0.9);
        padding: 20px;
        border-radius: 10px;
    }
    
    #gameCanvas {
        display: none;
    }
}

/* 小屏幕优化 */
@media (max-width: 480px) {
    .d-pad {
        width: 90px;
        height: 90px;
        bottom: 15px;
        left: 10px;
    }
    
    .action-buttons {
        bottom: 20px;
        right: 10px;
        gap: 12px;
    }
    
    .action-btn {
        width: 50px;
        height: 50px;
        font-size: 16px;
    }
    
    .d-pad-btn {
        width: 30px;
        height: 30px;
        font-size: 12px;
    }
}

/* ==========================================================================
   音效可视化（可选）
   ========================================================================== */
.audio-visualizer {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 3px;
    height: 20px;
    align-items: flex-end;
}

.audio-bar {
    width: 4px;
    background: #ff6b35;
    animation: audioWave 0.5s ease-in-out infinite alternate;
}

@keyframes audioWave {
    0% { height: 5px; }
    100% { height: 20px; }
}

/* ==========================================================================
   调试模式
   ========================================================================== */
.debug-mode {
    position: absolute;
    top: 80px;
    left: 10px;
    color: #0f0;
    font-size: 10px;
    z-index: 100;
    pointer-events: none;
}

/* 触摸屏禁用提示隐藏 */
body {
    -webkit-tap-highlight-color: transparent;
}

/* 游戏状态指示器 */
.game-state-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(16px, 4vw, 32px);
    color: #fff;
    text-shadow: 2px 2px 4px #000;
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.game-state-indicator.show {
    opacity: 1;
}